<?php
namespace Home\Controller;
use Common\Controller\CommonController;
class HomeController extends CommonController {
	protected $jsapi_ticket;
	public function _initialize(){
		parent::_initialize();
		$jsapi_ticket_time = $this ->config['jsapi_ticket_time'];
		$jsapi_ticket      = $this ->config['jsapi_ticket'];
		$time = time();
		if($time - $jsapi_ticket_time >=7200){
			$re = $this ->wechat ->getjsapi();
			$jsapi_ticket = $re['ticket'];
			M('Config')->where(array('key'=>'jsapi_ticket_time'))->setField('value',$time);
			M('Config')->where(array('key'=>'jsapi_ticket'))->setField('value',$jsapi_ticket);
		}
		$this ->jsapi_ticket = $jsapi_ticket;
	}
}